package cn.smile.controller.basic;

import cn.smile.bean.dto.basic.VoucherMemberDTO;
import cn.smile.bean.form.basic.voucher.QueryVouMemForm;
import cn.smile.business.basic.IVoucherMemberService;
import cn.smile.commons.response.MyResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/voucherMember")
public class VoucherMemberController {

    @Resource
    private IVoucherMemberService service;

    @GetMapping(value = "updateStatus")
    public MyResult<Boolean> updateStatus() {
        service.updateStatus();
        return MyResult.OK();
    }

    @PostMapping(value = "getPage")
    public MyResult<IPage<VoucherMemberDTO>> getPage(@RequestBody QueryVouMemForm form) {
        return MyResult.OK(service.getPage(form));
    }

    @PostMapping(value = "getList")
    public MyResult<List<VoucherMemberDTO>> getList(@RequestBody QueryVouMemForm form) {
        return MyResult.OK(service.getList(form));
    }

    @GetMapping(value = "usableNum")
    public MyResult<Integer> usableNum(@RequestParam("memberId") String memberId, @RequestParam("itemId") String itemId) {
        return MyResult.OK(service.usableNum(memberId, itemId));
    }
}
